package com.buer.train.business.service.impl;

import com.buer.train.business.dao.RoleDao;
import com.buer.train.business.domain.RoleDO;
import com.buer.train.business.service.RoleService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;



@Service
public class RoleServiceImpl implements RoleService {
	@Autowired
	private RoleDao roleDao;
	
	@Override
	public RoleDO get(Integer roleId){
		return roleDao.get(roleId);
	}
	
	@Override
	public List<RoleDO> list(Map<String, Object> map){
		return roleDao.list(map);
	}
	
	@Override
	public int count(Map<String, Object> map){
		return roleDao.count(map);
	}
	
	@Override
	public int save(RoleDO role){
		return roleDao.save(role);
	}
	
	@Override
	public int update(RoleDO role){
		return roleDao.update(role);
	}
	
	@Override
	public int remove(Integer roleId){
		return roleDao.remove(roleId);
	}
	
	@Override
	public int batchRemove(Integer[] roleIds){
		return roleDao.batchRemove(roleIds);
	}

    @Override
    public PageInfo<RoleDO> getRoleList(Map<String, Object> map) {
        PageHelper.startPage(map); //开始起始页
        List<RoleDO> list = roleDao.getRoleList(map); // 获取数据
        PageInfo<RoleDO> page = new PageInfo<>(list); // 实例化PageInfo
        return page;
    }

    @Override
    public RoleDO getOne(Map<String, Object> map){
        return roleDao.getOne(map);
    }

	@Override
	public RoleDO getRoleByUserId(Integer userId) {
		return roleDao.getRoleByUserId(userId);
	}

}
